package leetcode_401_500;

import java.util.ArrayList;
import java.util.List;

public class LeeCode_442 {
    public static void main(String[] args) {

    }
    private static List<Integer> findDuplicates(int[] nums) {
        List<Integer> ans = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            if (nums[Math.abs(nums[i]) - 1] < 0){
                ans.add(Math.abs(nums[i]));
            }else {
                nums[Math.abs(nums[i]) - 1] *= -1;
            }
        }
        return ans;
    }
}
